package folderLogger.GUI;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import folderLogger.GUI.Delegates.CallbackDelegate;
import folderLogger.GUI.FolderLoggerGUI.GetSettingsDelegate;

public class RunButtonActionListener implements ActionListener {

	private ScanThreadHandler worker;
	private CallbackDelegate callbackDelegate;
	private GetSettingsDelegate settingsDelegate;
	
	public RunButtonActionListener()	{
		this.callbackDelegate = null;
		this.settingsDelegate = null;
	}
	
	@Override
	public void actionPerformed(ActionEvent event) {
		worker = new ScanThreadHandler(callbackDelegate, settingsDelegate.getSettings());
		worker.execute();
	}
	
	public String getLastError() {
		return worker.getLastError();
	}

	public void setSettingsDelegate(GetSettingsDelegate settingsDelegate) {
		this.settingsDelegate = settingsDelegate;
	}
	
	public void setCallbackDelegate(CallbackDelegate callbackDelegate) {
		this.callbackDelegate = callbackDelegate;
		
	}
}
